home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / util / decigel2 / part01
Encoding:
Internet Message Format  |  1990-07-16  |  7.0 KB

  1. Path: xanth!cs.odu.edu!Amiga-Request
  2. From: Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v90i219: Decigel020 - avoid move sr,<ea> traps on mc680x0 (where 0<=x<=3), Part01/01
  5. Message-ID: <13144@xanth.cs.odu.edu>
  6. Date: 16 Jul 90 00:28:41 GMT
  7. Sender: tadguy@cs.odu.edu
  8. Reply-To: bryce@cbmvax.commodore.com (Bryce Nesbitt)
  9. Lines: 229
  10. Approved: tadguy@cs.odu.edu (Tad Guy)
  11. X-Mail-Submissions-To: Amiga@cs.odu.edu
  12. X-Post-Discussions-To: comp.sys.amiga
  13.  
  14. Submitted-by: bryce@cbmvax.commodore.com (Bryce Nesbitt)
  15. Posting-number: Volume 90, Issue 219
  16. Archive-name: util/decigel020/part01
  17.  
  18. [ uuencoded executable enclosed  ...tad ]
  19.  
  20. Decigel020    - The functionality of the famous "decigel" program, but
  21. working on the 68020/68030 processors.
  22.  
  23. The old Decigel would correctly patch the instruction on the 68020,
  24. but chances are the old (bad) instruction was still in the instruction
  25. cache.  This code flushes the cache after modifying memory.
  26.  
  27. This code may not function under future revisions of the operating
  28. system.  This code is safe on the 68000/68010/68020 and 68030.
  29. This code is not expected to function on the 68040.
  30.  
  31. If the instruction was MOVE SR,<ea> it is converted to MOVE CCR,<ea>. 
  32. The instruction cache is flushed, then the instruction is re-executed. 
  33.  
  34.  
  35. #!/bin/sh
  36. # This is a shell archive.  Remove anything before this line, then unpack
  37. # it by saving it into a file and typing "sh file".  To overwrite existing
  38. # files, type "sh file -c".  You can also feed this as standard input via
  39. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  40. # will see the following message at the end:
  41. #        "End of archive 1 (of 1)."
  42. # Contents:  decigel020.asm decigel020.uu
  43. # Wrapped by tadguy@xanth on Sun Jul 15 20:28:30 1990
  44. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  45. if test -f 'decigel020.asm' -a "${1}" != "-c" ; then 
  46.   echo shar: Will not clobber existing file \"'decigel020.asm'\"
  47. else
  48. echo shar: Extracting \"'decigel020.asm'\" \(3135 characters\)
  49. sed "s/^X//" >'decigel020.asm' <<'END_OF_FILE'
  50. X**
  51. X**
  52. X**  Decigel020    - The functionality of the famous "decigel" program, but
  53. X**  working on the 68020/68030 processors.
  54. X**
  55. X**  The old Decigel would correctly patch the instruction on the 68020,
  56. X**  but chances are the old (bad) instruction was still in the instruction
  57. X**  cache.  This code flushes the cache after modifying memory.
  58. X**
  59. X**  This code may not function under future revisions of the operating
  60. X**  system.  This code is safe on the 68000/68010/68020 and 68030.
  61. X**  This code is not expected to function on the 68040.
  62. X**
  63. X**
  64. X**  Written Tuesday 03-Apr-90 21:21:47 -Bryce Nesbitt
  65. X**
  66. X**
  67. X        INCLUDE "exec/types.i"
  68. X        INCLUDE "exec/memory.i"
  69. X        INCLUDE "exec/ables.i"
  70. X        INCLUDE "exec/execbase.i"
  71. X        INCLUDE "libraries/dosextens.i"
  72. X
  73. X        INT_ABLES
  74. X
  75. X        XREF    _LVOFindTask
  76. X        XREF    _LVOSupervisor
  77. X
  78. XABSEXECBASE    EQU 4
  79. XPrivTrapVector    EQU $20
  80. X
  81. X
  82. X
  83. X
  84. X;-------------- install patch then detach -----------------------------------
  85. X
  86. X        move.l    ABSEXECBASE,a6
  87. X
  88. X
  89. X        ;
  90. X        ;   Contents of the old vector are used to self-modify our
  91. X        ;   code.  The new vector replaces the old.
  92. X        ;
  93. X        DISABLE
  94. X        move.l    PrivTrapVector,ModifyCode+2
  95. X        bsr.s    FlushCache
  96. X        move.l    #NewPrivTrap,PrivTrapVector
  97. X        ENABLE
  98. X
  99. X
  100. X        ;
  101. X        ;   Detach our code from the CLI
  102. X        ;
  103. X        suba.l    a1,a1
  104. X        jsr    _LVOFindTask(a6)
  105. X        move.l    d0,a0
  106. X        move.l    pr_CLI(a0),a0
  107. X        add.l    a0,a0
  108. X        add.l    a0,a0
  109. X        move.l    a0,d0
  110. X        beq.s    not_cli
  111. X        clr.l    cli_Module(a0)
  112. Xnot_cli:    moveq    #0,d0
  113. X        rts
  114. X
  115. X
  116. X
  117. X
  118. X*
  119. X*   Flush the instruction cache
  120. X*
  121. XFlushCache:    movem.l a5/a6,-(sp)
  122. X        move.l    ABSEXECBASE,a6
  123. X        btst.b    #AFB_68020,AttnFlags+1(a6)  ;>=68020 includes cache
  124. X        beq.s    fc_nocache
  125. X
  126. X        lea.l    FlushTrap(pc),a5
  127. X        jsr    _LVOSupervisor(a6)
  128. X
  129. Xfc_nocache:    movem.l (sp)+,a5/a6
  130. X        rts
  131. X;
  132. X;
  133. XFlushTrap:    dc.w    $4e7a,$0002 ;movec.l CACR,d0
  134. X        bset    #3,d0        ;Set "Clear instruction cache" bit
  135. X        dc.w    $4e7b,$0002 ;movec.l d0,CACR
  136. X        rte
  137. X
  138. X
  139. X
  140. X
  141. X
  142. X*****************************************************************************
  143. X**                                       **
  144. X**                                       **
  145. X**  The trap handler wedged into the privilege violation vector.       **
  146. X**                                       **
  147. X**  If the instruction was MOVE SR,<ea> it is converted to MOVE CCR,<ea>.  **
  148. X**  The instruction cache is flushed, then the instruction is re-executed. **
  149. X**                                       **
  150. X**                                       **
  151. X*****************************************************************************
  152. X
  153. XSTKOFFSET    EQU    4*3
  154. X
  155. X;
  156. X;   New privilege violation vector
  157. X;
  158. XNewPrivTrap:    movem.l d0/a0/a6,-(sp)
  159. X        move.l    STKOFFSET+2(sp),a0
  160. X        move.w    (a0),d0             ; Examine opcode
  161. X        andi.w    #~%111111,d0        ; Mask out EA field
  162. X        cmpi.w    #$40C0,d0        ; A MOVE SR,<ea>?
  163. X        beq.s    GotOne
  164. X        movem.l (sp)+,d0/a0/a6
  165. XModifyCode:    jmp    $01234567        ; To previous handler... (exit)
  166. X
  167. X;
  168. X;   Code executed if the instruction was MOVE SR,<ea>
  169. X;
  170. XGotOne:     move.l    ABSEXECBASE,a6
  171. X
  172. X
  173. X        DISABLE
  174. X        bset    #1,(a0)             ; Convert to MOVE CCR,<ea>
  175. X        btst.b    #AFB_68020,AttnFlags+1(a6)  ;>=68020 includes cache
  176. X        beq.s    no_cache
  177. X
  178. X        dc.w    $4e7b,$8802 ; movec.l a0,CAAR
  179. X        dc.w    $4e7a,$0002 ; movec.l CACR,d0
  180. X        bset    #2,d0        ; Set "Clear entry in instruction cache"
  181. X        dc.w    $4e7b,$0002 ; movec.l d0,CACR
  182. Xno_cache:    ENABLE
  183. X
  184. X
  185. X        movem.l (sp)+,d0/a0/a6
  186. X        rte                ; Rerun new opcode... (exit)
  187. X
  188. X    END
  189. END_OF_FILE
  190. if test 3135 -ne `wc -c <'decigel020.asm'`; then
  191.     echo shar: \"'decigel020.asm'\" unpacked with wrong size!
  192. fi
  193. # end of 'decigel020.asm'
  194. fi
  195. if test -f 'decigel020.uu' -a "${1}" != "-c" ; then 
  196.   echo shar: Will not clobber existing file \"'decigel020.uu'\"
  197. else
  198. echo shar: Extracting \"'decigel020.uu'\" \(745 characters\)
  199. sed "s/^X//" >'decigel020.uu' <<'END_OF_FILE'
  200. Xbegin 644 decigel020
  201. XM```#\P`````````#``````````(````V``````````````/I````-BQX``0SN
  202. XM_$```-_PFE(N`28C^``@````DF$R(?P```!X`"!3+@$F;`@S_,```-_PFI/)Q
  203. XM3J[^VB!`(&@`K-'(T<@@"&<$0J@`/'``3G5(YP`&+'@`!`@N``$!*6<(2_H`X
  204. XM#$ZN_^),WV``3G5.>@`"",```TY[``).<TCG@((@;P`.,!`"0/_`#$!`P&<*D
  205. XM3-]!`4[Y`2-%9RQX``0S_$```-_PFE(N`28(T``!""X``0$I9Q!.>X@"3GH`W
  206. XM`@C```).>P`"4RX!)FP(,_S```#?\)I,WT$!3G,``````^P````"````````J
  207. XM`!0````<`````````_`````#14Y!0DQ%+C`U-@``````T`````-%3D%"3$4N^
  208. XM,#4U```````P`````TUO9&EF>4-O9&4``````)`````#3F5W4')I=E1R87``E
  209. XM````>`````-F8U]N;V-A8VAE``````!D`````T9L=7-H0V%C:&4``````$P`]
  210. XM```";F]?8V%C:&4```#"`````D=O=$]N90``````E@````-&;'5S:%1R87``T
  211. XM``````!J`````FYO=%]C;&D`````2`````````/R```#Z0````````/R```#U
  212. X)Z@````````/R?
  213. X``
  214. Xend
  215. Xsize 504
  216. END_OF_FILE
  217. if test 745 -ne `wc -c <'decigel020.uu'`; then
  218.     echo shar: \"'decigel020.uu'\" unpacked with wrong size!
  219. fi
  220. # end of 'decigel020.uu'
  221. fi
  222. echo shar: End of archive 1 \(of 1\).
  223. cp /dev/null ark1isdone
  224. MISSING=""
  225. for I in 1 ; do
  226.     if test ! -f ark${I}isdone ; then
  227.     MISSING="${MISSING} ${I}"
  228.     fi
  229. done
  230. if test "${MISSING}" = "" ; then
  231.     echo You have the archive.
  232.     rm -f ark[1-9]isdone
  233. else
  234.     echo You still need to unpack the following archives:
  235.     echo "        " ${MISSING}
  236. fi
  237. ##  End of shell archive.
  238. exit 0
  239. -- 
  240. Mail submissions (sources or binaries) to <amiga@cs.odu.edu>.
  241. Mail comments to the moderator at <amiga-request@cs.odu.edu>.
  242. Post requests for sources, and general discussion to comp.sys.amiga.
  243.